// index.js
const http = require('../../api/index');
const requsest = require('../../utils/request')
Page({
  
  data: {
    bannerData:"111",
    imgUrl: requsest.baseURL,
    selectCampList:[],//营地
    
    },
    onLoad(){
      this.getBanner();
    
    },
  
    onLoad(option){
      this.getBanner()
    
  
      // this.getBanner();
    },
    onShow(){
      http.campListSort().then(res=>{
        if(res.code == 200){
          res.rows.forEach(item=>{
            if(item.imageUrl.indexOf(',') != -1){
              item.images = item.imageUrl.split(',')
              item.imageUrl = item.images[0]
            }
          })
          let selectCampList = res.rows.filter(item=>{
            return item.show == 1
          })
          this.setData({
            selectCampList:selectCampList
          })
        }
      });
     this.getBanner()
    },
    goCampDetail(e){
      let id = e.currentTarget.dataset.id
      wx.navigateTo({
       
        url: `/pages/campDetail/index?campId=${id}`,
      })
    },
    getBanner(){
      http.getBannerList().then((res)=>{
        console.log("res:"+res);
        if(res.code === 200){
          let imageList = res.rows
          this.setData({
            bannerData: imageList
          })

          console.log('Data2',this.data)

          console.log(this.bannerList)
          wx.setStorageSync('banner',this.bannerList)

        }else{
          wx.showToast({
            title: res.msg,
            icon:'none'
          })
        }
      })
      console.log('获取广告数据',this.bannerList)
    },
 
    
})
